﻿<Page x:Class="Wokhan.WindowsFirewallNotifier.Console.UI.Pages.Options"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:Wokhan.WindowsFirewallNotifier.Console.UI.Pages"
      xmlns:settings="clr-namespace:Wokhan.WindowsFirewallNotifier.Common;assembly=Wokhan.WindowsFirewallNotifier.Common"
      xmlns:helpers="clr-namespace:Wokhan.WindowsFirewallNotifier.Common.Helpers;assembly=Wokhan.WindowsFirewallNotifier.Common"
      mc:Ignorable="d" 
      d:DesignHeight="600" d:DesignWidth="600"
      Title="Settings" DataContext="{Binding RelativeSource={RelativeSource Self}}">
    <DockPanel>
        <Border Background="#FFFF7B7B" Style="{StaticResource NonAdminPanel}">
            <WrapPanel>
                <Label Content="*Those options can only be modified by an administrator." />
                <Button x:Name="btnRestartAdmin" Click="btnRestartAdmin_Click">
                    <Grid>
                        <Path Height="16" HorizontalAlignment="Left" Stretch="Uniform" Fill="#FF5353F7" Data="{StaticResource Image_Shield}" />
                        <Label Margin="20,0,0,0" Padding="0" Content="restart as admin" />
                    </Grid>
                </Button>
            </WrapPanel>
        </Border>
        <Border Style="{StaticResource ToolBarPanel}">
            <WrapPanel HorizontalAlignment="Left">
                <Button x:Name="btnSave" Click="btnOK_Click">
                    <Grid>
                        <Path HorizontalAlignment="Left" Height="14" Stretch="Uniform" Fill="#FF6C6CD4" Data="{StaticResource Image_Shield}" />
                        <TextBlock Margin="20,0,0,0" Text="Apply" />
                    </Grid>
                </Button>
                <Button x:Name="btnRevert" Click="btnCancel_Click">
                    <Grid>
                        <Path HorizontalAlignment="Left" Height="14" Stretch="Uniform" Fill="Red" Data="{StaticResource Image_Refresh}" />
                        <TextBlock Margin="20,0,0,0" Text="Reload" />
                    </Grid>
                </Button>
            </WrapPanel>
        </Border>
        <StackPanel>
            <Label Content="Notifier settings" Background="{DynamicResource AccentColorBrush}" FontWeight="Bold" />
            <StackPanel Margin="10">
                <TextBlock Margin="0,0,0,10" TextWrapping="Wrap" Text="The following options only apply if you chose 'Block and prompt' for the outgoing connections in the Firewall settings page, as they target the WFN notification window." />
                <!--<Border BorderThickness="0" Background="#FFFF7B7B">
                    <Border.Style>
                        <Style TargetType="Border" BasedOn="{StaticResource InfoPanel}">
                            <Setter Property="Visibility" Value="Visible" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsAdmin}" Value="True">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                    <WrapPanel>
                        <Label Content="This feature is only enabled for administrators." />
                        <Button BorderBrush="LightGray" BorderThickness="1" x:Name="btnRestartAdmin" Click="btnRestartAdmin_Click">
                            <Grid>
                                <Path Height="16" HorizontalAlignment="Left" Stretch="Uniform" Fill="#FF5353F7" Data="{StaticResource Image_Shield}" />
                                <Label Margin="15,0,0,0" Content="restart as admin" />
                            </Grid>
                        </Button>
                    </WrapPanel>
                </Border>
                <StackPanel Margin="0,10,0,0"  IsEnabled="{Binding IsAdmin}">
                    <TextBlock TextWrapping="Wrap" TextAlignment="Justify" Text="By default, Windows allows all and every outgoing connections without asking for the user's consent, which obviously induces a security risk. Enabling the outgoing connections filter implies that some security settings will be strengthened (those settings can be restored to their default values when disabling WFN)." />
                    <GroupBox Padding="20,10" Margin="10" BorderThickness="0">
                        <GroupBox.Header>
                            <RadioButton HorizontalAlignment="Stretch" FontWeight="Bold" IsChecked="{Binding IsInstalled, Mode=OneTime}" GroupName="rbEnable" x:Name="rbEnable" Content="Enable the notifications" />
                        </GroupBox.Header>
                        <StackPanel IsEnabled="{Binding IsChecked,ElementName=rbEnable}">
                            <WrapPanel Margin="0,0,0,10">
                                <Label Content="Enable for: " />
                                <ComboBox IsEditable="False" SelectedIndex="{Binding EnableFor, Source={x:Static settings:Settings.Default}}">
                                    <ComboBoxItem Content="the current user" />
                                    <ComboBoxItem Content="everyone" />
                                </ComboBox>
                            </WrapPanel>
                            <CheckBox Content="Use an animated notification" Margin="0,0,0,10" IsChecked="{Binding UseAnimation, Source={x:Static settings:Settings.Default}}" />
                            <Button Content="Test" x:Name="btnTestNotif" Click="btnTestNotif_Click" />
                            <CheckBox Content="Create a blocking rule instead of using an exceptions list" Margin="0,0,0,5" IsChecked="{Binding UseBlockRules, Source={x:Static settings:Settings.Default}}" />
                            <TextBlock Margin="30,0,0,10" Text="This option allows the blocked applications to stay blocked even if you disable WFN notifications, by creating a blocking rule in the Windows embedded firewall." TextWrapping="Wrap" />
                            <CheckBox Content="Enable services detection" IsChecked="{Binding EnableServiceDetection, Source={x:Static settings:Settings.Default}}" />
                        </StackPanel>
                    </GroupBox>
                    <GroupBox Padding="20,10" Margin="10,0,10,10" BorderThickness="0">
                        <GroupBox.Header>
                            <RadioButton FontWeight="Bold" IsChecked="{Binding IsInstalled,Mode=OneTime,Converter={StaticResource booleanNegator}}" GroupName="rbEnable" x:Name="rbDisable" VerticalContentAlignment="Top" Content="Do not enable the notifications" />
                        </GroupBox.Header>
                        <StackPanel IsEnabled="{Binding IsChecked,ElementName=rbDisable}">
                            <TextBlock Text="You will still be able to use Windows Firewall Notifier console, but will not get any notification and will not allow outgoing connections filtering.
Please note that you will be able to do it later through the Options panel." TextAlignment="Justify" TextWrapping="Wrap" Margin="0,0,0,10"/>
                            <CheckBox x:Name="chkReallowOut" Content="Reallow unknown outgoing connections (default)" />
                            <TextBlock TextWrapping="Wrap" Text="Note: All blocking rules you created either manually or using this application will still be active." Margin="30,0,0,10" />
                            <CheckBox x:Name="chkDisableLog" Content="Disable the Windows firewall outgoing connections log (default)" />
                        </StackPanel>
                    </GroupBox>
                </StackPanel-->
                <ToggleButton Style="{StaticResource ToggleSwitch}" Padding="5,0" Content="Use an animated notification" Margin="0,0,0,10" IsChecked="{Binding UseAnimation, Source={x:Static settings:Settings.Default}}" />
                <Button Style="{StaticResource RoundedButton}" Background="LightBlue" Margin="0,0,0,10" Padding="4"  HorizontalAlignment="Center" Content="Click here to test" x:Name="btnTestNotif" Click="btnTestNotif_Click" />
                <ToggleButton Style="{StaticResource ToggleSwitch}" Padding="5,0" Content="Create a blocking rule instead of using an exceptions list for the blocked outgoing connections*" Margin="0,0,0,5" IsChecked="{Binding UseBlockRules, Source={x:Static settings:Settings.Default}}" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}" />
                <TextBlock Margin="30,0,0,10" Text="This option allows the blocked applications to stay blocked even if you disable WFN notifications, by creating a blocking rule in the Windows embedded firewall." TextWrapping="Wrap" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}" />
                <ToggleButton Style="{StaticResource ToggleSwitch}" Padding="5,0" Content="Enable services detection*" IsChecked="{Binding EnableServiceDetection, Source={x:Static settings:Settings.Default}}" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}" />                
            </StackPanel>
            <Label Content="Miscellaneous options" Background="{DynamicResource AccentColorBrush}" FontWeight="Bold" />
            <StackPanel Margin="10">
                <ToggleButton Style="{StaticResource ToggleSwitch}" Margin="0,0,0,10"  Padding="5,0" Content="Minimize the console to the system tray instead of the taskbar." IsChecked="{Binding MinimizeToTray, Source={x:Static settings:Settings.Default}}" />
                <ToggleButton Style="{StaticResource ToggleSwitch}" Margin="0,0,0,10" Padding="5,0" Content="Enable verbose logging (for debugging purpose only, may use a lot more disk space)" IsChecked="{Binding EnableVerboseLogging, Source={x:Static settings:Settings.Default}}" />
                <TextBlock Margin="30,0,0,10" Text="Note: the log files can either be in the WFN installation directory or the current user's appdata folder." />
                <TextBlock Margin="30,0,0,10" Text="{Binding Source={x:Static helpers:LogHelper.CurrentLogsPath},Mode=OneTime,StringFormat='Path for the current user: {0}'}" Tag="{Binding Source={x:Static helpers:LogHelper.CurrentLogsPath}, Mode=OneTime}" x:Name="txtCurrentLogPath" MouseDown="txtCurrentLogPath_MouseDown"/>
                <ToggleButton Style="{StaticResource ToggleSwitch}" Margin="0,0,0,10" Padding="5,0" Content="Always run as admin*" IsChecked="{Binding AlwaysRunAs, Source={x:Static settings:Settings.Default}}" IsEnabled="{Binding IsElevated,Source={x:Static Application.Current}}" />
                <WrapPanel>
                    <Label Content="Accent color: " />
                    <ComboBox IsEditable="False" MinWidth="100" ItemsSource="{Binding Colors}" SelectedValuePath="Value" SelectedValue="{Binding AccentColor}">
                        <ComboBox.ItemTemplate>
                            <DataTemplate>
                                <WrapPanel>
                                    <Rectangle Width="10" Height="10" Fill="{Binding Value}" />
                                    <Label Content="{Binding Key}" />
                                </WrapPanel>
                            </DataTemplate>
                        </ComboBox.ItemTemplate>
                    </ComboBox>
                </WrapPanel>
            </StackPanel>
        </StackPanel>
    </DockPanel>
</Page>
